<template>
	<view :class="[circle === true || circle === 'true' ? 'uni-fav--circle' : '']" :style="[{ backgroundColor: checked ? bgColorChecked : bgColor }]"
	 @click="onClick" class="uni-fav">
		<!-- #ifdef MP-ALIPAY -->
		<view class="uni-fav-star" v-if="!checked && (star === true || star === 'true')">
			<uni-icons :color="fgColor" :style="{color: checked ? fgColorChecked : fgColor}" class="uni-fav-star" size="25" type="star" />
		</view>
		<!-- #endif -->
		<!-- #ifndef MP-ALIPAY -->
		<uni-icons :color="fgColor" :style="{color: checked ? fgColorChecked : fgColor}" class="uni-fav-star" size="25" type="star"
		 />
		<!-- #endif -->
		<text  :style="{color: checked ? fgColorChecked : fgColor}" class="uni-fav-text">{{ checked ? contentText.contentFav : contentText.contentDefault }}</text>
	</view>
</template>

<script>
	import uniIcons from "../uni-icons/uni-icons.vue";
	export default {
		name: "UniFav",
		components: {
			uniIcons
		},
		props: {
			star: {
				type: [Boolean, String],
				default: true
			},
			bgColor: {
				type: String,
				// default: "#cccccc"
			},
			fgColor: {
				type: String,
				// default: "red"
			},
			bgColorChecked: {
				type: String,
				default: "#fffff"
			},
			fgColorChecked:{
				type: String,
				default: "red"
			},
			circle: {
				type: [Boolean, String],
				default: false
			},
			checked: {
				type: Boolean,
				// default: false
			},
			contentText: {
				type: Object,
				default () {
					return {
						contentDefault: "收藏",
						contentFav: "收藏"
					};
				}
			}
		},
		watch: {
			checked() {
				
				
			}
			
		},
		methods: {
			onClick() {
				this.$emit("click");
			}
		}
	};
</script>

<style lang="scss" scoped>
	$fav-height:48rpx;

	.uni-fav {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		// width: 60px;
		height: $fav-height;
		line-height: $fav-height;
		text-align: center;
		
		// font-size: 100px;
		// border-radius: 3px;
		
	}

	.uni-fav--circle {
		// border-radius: 30px;
	}

	.uni-fav-star {
		/* #ifndef APP-NVUE */
		display: flex;
		
		/* #endif */
		
		height: $fav-height;
		// line-height: 14px;
		margin-right: 3px;
		align-items: center;
		justify-content: center;
		
	}

	.uni-fav-text {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		height: $fav-height;
		line-height: $fav-height;
		align-items: center;
		justify-content: center;
		// font-size: $uni-font-size-base;
		font-size: 15px;
  margin-top: 8rpx;		
	}
</style>
